package com.wanmei.pojo;

import java.util.HashMap;
import java.util.Map;

/**
 * 用来存储json的返回值类型
 */
public class JsonResult {

    private int code;
    private String msg;
    private Map<String, Object> extendInfo = new HashMap<String, Object>();

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Map<String, Object> getExtendInfo() {
        return extendInfo;
    }

    public void setExtendInfo(Map<String, Object> extendInfo) {
        this.extendInfo = extendInfo;
    }

    public  JsonResult success() {
        JsonResult result = new JsonResult();
        result.setCode(1);
        result.setMsg("操作成功！");
            return result;
    }
    public  JsonResult fail(){
        JsonResult result = new JsonResult();
        result.setCode(0);
        result.setMsg("操作失败！");
        return result;
    }
    public  JsonResult addInfo(String key,Object object){
        this.extendInfo.put(key,object);
        return this;
    }
}
